from django.db import models

from seller import models as smodels


# Create your models here.
#  购物者
class User(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    pwd = models.CharField(max_length=32)
    email = models.CharField(max_length=32)
    phone = models.CharField(max_length=32)
    address = models.CharField(max_length=255)


#  购物车

class Cart(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    price = models.CharField(max_length=32)
    goodsnum = models.IntegerField()
    goodsimg = models.CharField(max_length=32)
    # xiaoji = models.DecimalField(max_digits=5, decimal_places=2)
    goodsid = models.IntegerField()
    user = models.ForeignKey(to='User', on_delete=models.CASCADE)


# 地址
class UserAddress(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    detailadd = models.TextField()
    youbian = models.CharField(max_length=32)
    phone = models.CharField(max_length=32)
    status = models.BooleanField(default=False)  # 设置地址的选中状态
    user = models.ForeignKey(to='User', on_delete=models.CASCADE)


# 订单
class Order(models.Model):
    id = models.AutoField(primary_key=True)
    orderno = models.CharField(max_length=32)
    ordertime = models.DateTimeField()  # 下单时间
    ordertotal = models.CharField(max_length=32)
    # 订单状态
    orderstatus = models.BooleanField(default=False)  # 设置订单的状态
    orderaddress = models.TextField()
    user = models.ForeignKey(to='User', on_delete=models.CASCADE)

# 订单详情
class OrderDetails(models.Model):
    id = models.AutoField(primary_key=True)
    goodsname = models.CharField(max_length=32)
    goodsprice = models.CharField(max_length=32)
    goodsnum = models.IntegerField()
    goodsimg = models.CharField(max_length=32)
    goodsxiaoji = models.CharField(max_length=32)
    order = models.ForeignKey(to='Order', on_delete=models.CASCADE)
